var http = require("http");
var fs   = require("fs");

//三个模块
var url  = require("url");
var path = require("path");
var querystring = require("querystring");

http.createServer((req,res) => {
    //设置页面编码
    res.setHeader("Content-type","text/html;charset=UTF-8");
    //转为对象
    var urljson =url.parse(req.url);

    //得到文件的路径
    var pathname=urljson.pathname;

    //得到文件的扩展名
    var extname = path.extname(pathname);

    //得到查询字符串
    var qs = urljson.query;

    //转为查询对象，和url.parse加上true非常类似
    var qsjson =querystring.parse(qs);

    console.log(pathname);
    console.log(extname);
    res.end("");
}).listen(3000);

console.log("NodeJS Server Start at 3000 port");